<template>
  <div class="customFormNull" v-if="check"></div>
  <span v-else>{{ convertNumber(value) }}</span>
</template>

<script>
export default {
  name: "formulaNumber",
  data() {
    return {};
  },
  props: ["value", "record", "disabled"],
  computed: {
    /**
     * 其他字段
     */
    check() {
      var isNaN = this.$utils.isNaN(this.value);
      if (
        this.value == null ||
        this.value == "" ||
        this.value == "Infinity" ||
        isNaN
      ) {
        return true;
      }
      return false;
    },
  },
  methods: {
    /**
     * 数量格式化
     */
    convertNumber(data) {
      var options = this.record.options;
      //千分位
      if (options.percentile && data) {
        data = this.$utils.commafy(Number(data), {
          digits: options.precision,
        });
      } else {
        if (options.precision && data) {
          data = this.$utils.toNumber(data).toFixed(options.precision);
        }
      }
      var value = options.addonBefore + data + options.addonAfter;
      return value;
    },
  },
};
</script>
<style lang="less" scoped>
.customFormNull {
  background: #eaeaea;
  border-radius: 3px;
  height: 6px;
  margin: 15px 0;
  width: 22px;
}
</style>
